package com.ParkingManager.app.web;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.ParkingManager.app.service.DoorKeeperService;

@RestController
public class DoorKeeperController {
	
	@Autowired
	DoorKeeperService doorKeeperService;
	/**
	 * 上传图片
	 * @param uploadImage
	 * @return 图像识别的结果
	 */
	@RequestMapping("/uploadImg")
	Map imgAccept(MultipartFile file){
		System.out.println("你好");
		System.out.println(file.getOriginalFilename());
		Map<String,Object> ret = new HashMap<String, Object>();
		ret.put("code", 0);
		ret.put("carNo", doorKeeperService.carImgDeal(file));
		return ret;
	}
	
	@RequestMapping("/carIn")
	int carIn(String carId,String carType,String image){
		return doorKeeperService.carIn(carId, carType, image);
	}
	
	@RequestMapping("/carOut")
	boolean carOut(String carId,String carType,String image){
		return doorKeeperService.carOut(carId,carType, image);
	}
	
	@RequestMapping("/carNum")
	int[] carNum(){
		return doorKeeperService.getCarMaxAndNow();
	}
	
	@RequestMapping("/listCar")
	List<HashMap<String, Object>> listCar(){
		return doorKeeperService.listCar();
	}
	
	@RequestMapping("/findCar")
	List<HashMap<String, Object>> findCar(String carNo){
		List<HashMap<String, Object>> ret = new ArrayList<HashMap<String, Object>>();
		ret.add(doorKeeperService.findCar(carNo));
		return ret;
	}
	
	@RequestMapping("/getRecordId")
	int getRecordId(String carId){
		return doorKeeperService.getRecordId(carId);
	}
}
